package application;

import javax.swing.ImageIcon;

import enums.CellType;

import application.food.Food;
/**
 * represents a Snake Game Matrix Cell. Has a coordinate and type. If type is 
 * an instance of Food, then the Food field must be initialized to a non null
 * Food object
 * @author Idan
 *
 */
public class Cell {
	private Coordinate _coord;
	private CellType _type;
	private Food _food;
	private ImageIcon[] _im;
	/**
	 * constructor. Initialize _type to NONE and _food to null 
	 * @param c coordinate
	 */
	public Cell(Coordinate c){
		this.set_coord(c);
		this.set_type(CellType.NONE);
		this.set_food(null);
		_im = new ImageIcon[1];
	}
	/**
	 * resets cell to contain nothing
	 */
	public void resetCell() {
		this._type = CellType.NONE;
		this._food = null;
		this._im = null;
	}
	/**
	 * setter
	 * @param _coord
	 */
	public void set_coord(Coordinate _coord) {
		this._coord = _coord;
	}
	/**
	 * getter
	 * @return
	 */
	public Coordinate get_coord() {
		return _coord;
	}
	/**
	 * setter
	 * @param _type
	 */
	public void set_type(CellType _type) {
		this._type = _type;
	}
	/**
	 * getter
	 * @return
	 */
	public CellType get_type() {
		return _type;
	}
	/**
	 * setter
	 * @param _food
	 */
	public void set_food(Food _food) {
		this._food = _food;
	}
	/**
	 * getter
	 * @return
	 */
	public Food get_food() {
		return _food;
	}
	/**
	 * getter
	 * @return
	 */
	public ImageIcon getIcon(){
		return this._im[0];
	}
	public void set_im() {
		String filename = this._food.toFileName();
		GameManager.print(filename);
		this._im[0] = new ImageIcon(filename);
	}
}
